#!C:\Python27\python
import sys
import os
import plHandler
from Output import output

baseDir="."

method = os.environ.get("REQUEST_METHOD")
fileName = baseDir + os.environ.get("PATH_INFO", "")


#print "Content-Type: text/plain\r\n\r\n"
'''
print "method", method
print "request", fileName
'''

if sys.platform == "win32":
    import msvcrt
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)

if method == "GET":
    logfile = file("log.txt", "a")
    logfile.write(method + ": " + fileName + "\n")

playlist = plHandler.playlistHandler(output.STDMODE)
playlist.HandleRequest(method, fileName)

if method == "GET":
    logfile.close()